clear;clc;

load('Result_Baseline.mat');
%% Setup
% Information Structure
Info            =   struct();
Info.FixedParam =   struct('RHO_Z',0.81);
Info.ParamList  =   {'RHO_M',...
                     'Taylor_Pi','Taylor_ir' ...
                     };

Info.ParamNum   =   length(Info.ParamList);

Info.StdVec     =   [1 -1/4]'*0.01;
Info.Mom_Data   =   [1;-0.8/4;0.6];
Info.Weight     =   ones(3,1);
% Optimization 
ParaVec_0       =   [0.75;1.5;0.5];               
lb              =   [0.25;1.1;0.0];
ub              =   [0.95;5.0;0.9];

ObjFunction     =   @(Input)SubFun_Calibration_Eval(PP,SS,MODEL,EquJac,Info,Input);


%% Global Optimization
warning('off','all');

%--------------------------------------------------------------------------
% Particle Swarm
%--------------------------------------------------------------------------
rng default
options             =   optimoptions('particleswarm',...
                                     'Display','iter',...'SwarmSize',100.'HybridFcn',@fmincon,..
                                     'MaxTime',60*60*2,'UseParallel',true);
[ParamVec,fval,exitflag] ...
                    =   particleswarm(ObjFunction,length(lb),lb,ub,options);

[~,Mom_Model]       =   ObjFunction(ParamVec);

save('Calibration.mat','Info','Mom_Model','ParamVec');